import request from "@/utils/request"
import type { AttrListModel, AttrModel, CategoryIdsModel } from "./model/attrsModel";

enum API{
  // GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
  GetAttrsList="/admin/product/attrInfoList",
  // POST /admin/product/saveAttrInfo
  SaveAttr="/admin/product/saveAttrInfo",
  // DELETE /admin/product/deleteAttr/{attrId}
  DeleteAttr="/admin/product/deleteAttr",
}


// 获取平台属性值列表
export const GetAttrsListApi=(params:CategoryIdsModel)=>{
  return request.get<any, AttrListModel>(API.GetAttrsList+`/${params.category1Id}/${params.category2Id}/${params.category3Id}`)
}

// 添加或修改
export const SaveAttrApi=(attr:AttrModel)=>{
  return request.post(API.SaveAttr,attr)
}
// 删除
export const  DeleteAttrApi=(attrid:number)=>{
  return request.delete(API.DeleteAttr+`/${attrid}`)
}